package com.lineage.server.command.executor;

import com.add.system.L1BlendTable;
import com.lineage.config.ConfigErrorException;
import com.lineage.config.ConfigWho;
import com.lineage.config.Configtype;
import com.lineage.server.Instance.character.CharacterPunishInstance;
import com.lineage.server.datatables.BeginnerTable;
import com.lineage.server.datatables.CommandsTable;
import com.lineage.server.datatables.DropLimitTable;
import com.lineage.server.datatables.DropMapTable;
import com.lineage.server.datatables.DropMobTable;
import com.lineage.server.datatables.DropTable;
import com.lineage.server.datatables.DungeonTable;
import com.lineage.server.datatables.EventTable;
import com.lineage.server.datatables.ItemBoxTable;
import com.lineage.server.datatables.ItemMsgTable;
import com.lineage.server.datatables.ItemPowerUpdateTable;
import com.lineage.server.datatables.ItemTable;
import com.lineage.server.datatables.MapHprMprRangeTable;
import com.lineage.server.datatables.MobSkillTable;
import com.lineage.server.datatables.NPCTalkDataTable;
import com.lineage.server.datatables.NpcTable;
import com.lineage.server.datatables.ShopCnTable;
import com.lineage.server.datatables.ShopTable;
import com.lineage.server.datatables.ShopXTable;
import com.lineage.server.datatables.SkillsProbabilityTable;
import com.lineage.server.datatables.SkillsTable;
import com.lineage.server.datatables.WeaponSkillPowerTable;
import com.lineage.server.datatables.WeaponSkillTable;
import com.lineage.server.datatables.YiwaTable;
import com.lineage.server.datatables.mapuleTable;
import com.lineage.server.datatables.pageliaoTable;
import com.lineage.server.datatables.shahaTable;
import com.lineage.server.datatables.sql.AuctionBoardTable;
import com.lineage.server.datatables.sql.DwarfForChaTable;
import com.lineage.server.datatables.sql.IpTable;
import com.lineage.server.datatables.yinhaisaTable;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.william.ArmorSkillSound;
import com.lineage.william.ItemAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class L1Reload implements L1CommandExecutor {
  private static final Log _log = LogFactory.getLog(L1Reload.class);
  
  public static L1CommandExecutor getInstance() {
    return new L1Reload();
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    if (arg.equalsIgnoreCase("banip")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入banip资料。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("ban_ip重读成功"));
      } 
      IpTable.get().load();
    } 
    if (arg.equalsIgnoreCase("GmCMD")) {
      CommandsTable.get().load();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("GM_Command重读成功"));
    } 
    if (arg.equalsIgnoreCase("掉落")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入掉宝资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入掉宝资料数量。"));
      } 
      DropTable.get().load();
    } else if (arg.equalsIgnoreCase("RangeMap")) {
      MapHprMprRangeTable.get().load();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("w_RangeMapHpMpr"));
    } else if (arg.equalsIgnoreCase("道具制作")) {
      ItemAction.reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("w_道具制作系统-资料库更新"));
    } else if (arg.equalsIgnoreCase("指定掉落地图")) {
      DropMapTable.get().load();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("w_指定地图掉落-掉落资料库更新"));
    } else if (arg.equalsIgnoreCase("商店")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入商店贩卖资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入商店贩卖资料数量。"));
      } 
      ShopTable.get().load();
    } else if (arg.equalsIgnoreCase("防具")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入防具资料。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入防具资料。"));
      } 
      ItemTable.get().loadarmors();
    } else if (arg.equalsIgnoreCase("武器")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入武器资料。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入武器资料。"));
      } 
      ItemTable.get().loadweapons();
    } else if (arg.equalsIgnoreCase("道具")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入道具资料。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入道具资料。"));
      } 
      ItemTable.get().loaditems();
    } else if (arg.equalsIgnoreCase("NPC对话资料")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入NPC对话资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入NPC对话资料数量。"));
      } 
      NPCTalkDataTable.get().load();
    } else if (arg.equalsIgnoreCase("禁止拍卖")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入禁止拍卖物品资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入禁止拍卖物品资料数量。"));
      } 
      ShopXTable.get().load();
    } else if (arg.equalsIgnoreCase("技能")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入技能设置资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入技能设置资料数量。"));
      } 
      SkillsTable.get().load();
    } else if (arg.equalsIgnoreCase("伺服器活动")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入活动设置资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入活动设置资料数量。"));
      } 
      EventTable.get().load();
    } else if (arg.equalsIgnoreCase("mobskills")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入MOB技能资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入MOB技能资料数量。"));
      } 
      MobSkillTable.getInstance().loadMobSkillData();
    } else if (arg.equalsIgnoreCase("武器技能能力")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入技能武器设置资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入技能武器设置资料数量。"));
      } 
      WeaponSkillPowerTable.get().load();
    } else if (arg.equalsIgnoreCase("武器技能")) {
      WeaponSkillTable.get().load();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("weapon_skill-资料库更新"));
    } else if (arg.equalsIgnoreCase("限制掉落")) {
      DropLimitTable.getInstance().reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("william_drop_limit_item-资料库更新"));
    } else if (arg.equalsIgnoreCase("角色仓库")) {
      DwarfForChaTable.get().load();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("角色仓库-资料库更新"));
    } else if (arg.equalsIgnoreCase("地图切换点")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入地图切换点设置数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入地图切换点设置数量。"));
      } 
      DungeonTable.get().load();
    } else if (arg.equalsIgnoreCase("npc")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入NPC设置资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("重新载入NPC设置资料数量。"));
      } 
      NpcTable.get().load();
    } else if (arg.equalsIgnoreCase("赞助商店")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入商店贩卖资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("shop_cn-资料库更新。"));
      } 
      ShopCnTable.get().restshopCn();
    } else if (arg.equalsIgnoreCase("全怪掉宝")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入全怪掉宝资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("w_全服掉落-资料库更新。"));
      } 
      DropMobTable.get().load();
    } else if (arg.equalsIgnoreCase("火神")) {
      if (pc == null) {
        _log.warn("系统命令执行: " + cmdName + "重新载入w_火神装备制作资料数量。");
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("w_火神装备制作-资料库更新。"));
      } 
      L1BlendTable.getInstance().loadBlendTable();
    } else if (arg.equalsIgnoreCase("宝箱") || arg.equalsIgnoreCase("box")) {
      ItemBoxTable.reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("[etcitem_box].[etcitem_box_key].[etcitem_boxs]宝箱更新完成"));
    } else if (arg.equalsIgnoreCase("血盟小屋")) {
      AuctionBoardTable.reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("血盟小屋更新完成"));
    } else if (arg.equalsIgnoreCase("娃娃升级表")) {
      ItemPowerUpdateTable.reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("server_item_power_update更新完成"));
    } else if (arg.equalsIgnoreCase("出生装备")) {
      BeginnerTable.reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("BeginnerTable更新完成"));
    } else if (arg.equalsIgnoreCase("技能机率")) {
      SkillsProbabilityTable.get();
      SkillsProbabilityTable.reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("skills_pc_probability更新完成"));
    } else if (arg.equalsIgnoreCase("武卷防卷设定表")) {
      try {
        Configtype.load();
      } catch (ConfigErrorException e) {
        e.printStackTrace();
      } 
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("武卷防卷设定表-资料库更新"));
    } else if (arg.equalsIgnoreCase("WHO设定表")) {
      try {
        ConfigWho.load();
      } catch (ConfigErrorException e) {
        e.printStackTrace();
      } 
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("WHO设定表-资料库更新"));
    } else if (arg.equalsIgnoreCase("装备持续特效")) {
      ArmorSkillSound.getInstance();
      ArmorSkillSound.reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("w_装备持续特效-资料库更新"));
    } else if (arg.equalsIgnoreCase("punish")) {
      CharacterPunishInstance.get().reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("玩家惩罚名单-资料更新"));
    } else if (arg.equalsIgnoreCase("掉落广播")) {
      ItemMsgTable.get().reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("w_掉落广播-资料更新"));
    } else if (arg.equalsIgnoreCase("pag")) {
      pageliaoTable.get().reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("帕格里奥纹样-资料更新"));
    } else if (arg.equalsIgnoreCase("mapu")) {
      mapuleTable.get().reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("马普勒纹样-资料更新"));
    } else if (arg.equalsIgnoreCase("yiwa")) {
      YiwaTable.get().reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("伊娃纹样-资料更新"));
    } else if (arg.equalsIgnoreCase("sha")) {
      shahaTable.get().reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("沙哈纹样-资料更新"));
    } else if (arg.equalsIgnoreCase("yin")) {
      yinhaisaTable.get().reload();
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("殷海萨纹样-资料更新"));
    } 
  }
}
